<template>
	
	<div>
		<div style="padding: 10px;"  v-html="article"></div>
		<div style="width: 100%;padding-bottom: 3rem;">
			<div @click="toBack" style="width: 14rem;background: #FF9913;height: 2rem;margin: auto;text-align: center;color: #fff;border-radius: 0.3rem;">返回</div>
		</div>
	</div>

    
    
    
  
</template>

<script>
import { base64} from 'vux'

export default {
	
	components: {
		    base64
		  },
	
	data () {
		
	    return {
	      
	      article:'',
	      access_token:''
	     
	    }
	},
	
	methods:{
		
		//获取详情
	    getDetail(){
	    	  
			this.$store.commit('updateLoadingStatus',true);
			  
	    	this.$http.get(this.$store.state.api + 'userdd/article&access_token=' + this.access_token + '&article_cat_id=' + 3)
		    .then((response) => {
		    		
		    console.log(response)
				
				if(response.body.code == 0) {
					
					this.article = response.body.data.article
					console.log(this.article)
					
				} else {
					
				}
					
				
				this.$store.commit('updateLoadingStatus',false);		
				
			  }, (response) => {
	             
	             
			  });
	    },
	    
	    //返回
	    toBack(){
	    	
	    	this.$router.push({ path: '/user'});
	    	
	    },
	    
	    //获取地址栏信息
		getUrlStr(name){
	      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
	      if(reg.test(window.location.href)){
	        return unescape(RegExp.$2.replace(/\+/g," "))
	      }
	      return undefined
	    },
		
		
	},
	
	mounted() {
		
		var access_token = this.getUrlStr('access_token');
           var parentId = this.getUrlStr('parent_id');
           
            if(parentId == undefined){
              parentId = 0;
           }
           
           var uid = this.getUrlStr('uid');
           
           console.log(parentId.toString().indexOf('?'));
           
           if(parentId.toString().indexOf('?') > 0){
           	 parentId = parentId.split('?')[0];
           }
           
           
//         var uid = this.getUrlStr('uid');

           var locurl = location.href;
           locurl = base64.encode(locurl.split('?')[0]);
//		   locurl = locurl.replace(/\//g, "@@");
           
           console.log('-1-'+access_token)
           console.log('-2-'+parentId)
           console.log('-4-'+uid)
          
          
       
           if(access_token != undefined){
         
              localStorage.setItem("access_token",access_token); 
              localStorage.setItem("parent_id",this.getUrlStr('uid'));


           }
           
           console.log('-3-'+localStorage.getItem('access_token'));
           
            if(localStorage.getItem('access_token') != null){
         
              this.$root.registerjudge();
              this.$root.getShare();
              
            }else{
            	
            	console.log(222);
        	  this.$root.gotoWechat(locurl,parentId);
            }
           
       
         
    	   this.access_token = localStorage.getItem('access_token');

        this.getDetail();

  },
	
	
	
}


</script>

<style>
	
	html,body{
		width: 100%;
	}
	img{
		width: 100%;
	}
	
</style>